// Author: wsfuyibing <682805@qq.com>
// Date: 2025-05-23

package list

import (
	"server/app/http/models"
	"server/app/kind"
)

type (
	// Response
	// 会员出参.
	Response struct {
		Id             int64
		ArcadeId       kind.ArcadeId
		UserId         kind.UserId
		AvailableBegin string
		AvailableEnd   string
		AvailableMonth int
		OrderCount     int
		TicketCount    int
		SpendTotal     float64
		ReturnedTotal  float64

		Profile *ProfileResponse
	}

	// ProfileResponse
	// 用户出参.
	ProfileResponse struct {
		Id       kind.UserId
		Mobile   kind.Mobile
		Gender   kind.Gender
		Nickname string
		Avatar   string
	}
)

func (o *Response) With(m *models.ArcadeMember) *Response {
	o.Id = m.Id
	o.ArcadeId = m.ArcadeId
	o.UserId = m.UserId
	o.AvailableBegin = m.AvailableBegin.Time().Format("2006/01/02")
	o.AvailableEnd = m.AvailableEnd.Time().Format("2006/01/02")
	o.AvailableMonth = m.AvailableMonth
	o.OrderCount = m.OrderCount
	o.TicketCount = m.TicketCount
	o.SpendTotal = m.SpendTotal
	o.ReturnedTotal = m.ReturnedTotal
	return o
}

func (o *Response) WithUser(m *models.Users) *Response {
	o.Profile = &ProfileResponse{
		Id:       m.Id,
		Mobile:   m.Mobile,
		Gender:   m.Gender,
		Nickname: m.Nickname,
		Avatar:   m.Avatar,
	}
	return o
}
